package com.lingshi.yingzaitownmap.controller;

import com.lingshi.yingzaitownmap.entity.dto.AttractionPageQueryDTO;
import com.lingshi.yingzaitownmap.entity.result.PageResult;
import com.lingshi.yingzaitownmap.entity.result.Result;
import com.lingshi.yingzaitownmap.service.AttractionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/attractions")
@Slf4j
public class AttractionController {
    @Autowired
    private AttractionService attractionService;
    @GetMapping
    public Result<PageResult> list(AttractionPageQueryDTO attractionPageQueryDTO) {
        log.info("分页查询,参数为:{}",attractionPageQueryDTO);
        PageResult pageResult = attractionService.list(attractionPageQueryDTO);
        return Result.success(pageResult);
    }

    @GetMapping("/{id}")
    public Result getById(@PathVariable Integer id) {
        log.info("查询id为{}的景点",id);
        return Result.success(attractionService.getbyId(id));
    }

}
